package com.ruoyi.app.config.platform;

import java.math.BigDecimal;
import java.math.RoundingMode;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * <p>
 * 作用：平台配置
 * </p>
 *
 * @author Zane
 * @since 2025-10-19 11:19
 */
@Configuration
@Getter
public class PlatFormConfig {

  @Value("${platform.name:撮合平台}")
  private String name;
  @Value("${platform.id:2}")
  private Long id;
  @Value("${platform.linkUser:平台客服}")
  private String linkUser;
  @Value("${platform.phone:18800008888}")
  private String phone;
  @Value("${platform.commission.rate:0.1}")
  private Float commissionRate;

  public BigDecimal calculateAmountContainCommission(BigDecimal amount) {
    ///1+系数
    return amount.multiply(BigDecimal.ONE.add(new BigDecimal(commissionRate)))
        .setScale(2, RoundingMode.HALF_UP);
  }

  public BigDecimal calculateCommission(BigDecimal amount) {
    ///系数
    return amount.multiply(new BigDecimal(commissionRate))
        .setScale(2, RoundingMode.HALF_UP);
  }
}
